package com.rwy.dto;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.rwy.util.DateUtil;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StatisticDeviceDTO implements Serializable {

	/**
	 * Not
	 */
	private static final long serialVersionUID = 1L;

	private Integer termimalID;
	private String terminalCode;
	private Integer printKindID;
	private Integer printCount;
	private String salesNetworkName; //商家网点
	private Integer salesNetworkID;// 网点ID
	private List<RespItemDTO> list;

	private String startTime;
	private String endTime;
	private Integer dateType;
	private Integer type;

	private Integer page;
	private Integer pageSize;
	private Integer businessPartnerID;
	private List<Integer> partnerIDS;
	
	
	public StatisticDeviceDTO buildStartTime() {
		if (dateType == null || (dateType < 1 && dateType > 3))
			this.dateType = 2;
		String str = "";
		switch (dateType) {
			case 1 :
				str = DateUtil.getSimpleDate(new Date());
				//测试
				//str = DateUtil.getCurrentDayNDayDate(-1);
				break;
			case 2 :
				Date bf7 = DateUtil.getCurrentDayNDayDates(-6);
				Date fd = DateUtil.getCurrentMonthFirstDay();
				str = bf7.compareTo(fd) > 0 ? DateUtil.getSimpleDate(bf7) : DateUtil.getSimpleDate(fd);
				break;
			case 3 :
				str = DateUtil.getSimpleDate(DateUtil.getCurrentMonthFirstDay());
				break;
			default :
				break;
		}
		this.startTime = str + " 00:00:00";
		return this;
	}

	public StatisticDeviceDTO buildEndTime() {
		this.endTime = DateUtil.getSimpleDate(new Date()) + " 23:59:59";
		////测试使用
		//this.endTime = "2017-05-15 23:59:59";
		return this;
	}

	public StatisticDeviceDTO pageSize(Integer pageSize) {
		if (pageSize == null || pageSize < 5)
			pageSize = 20;
		this.pageSize = pageSize;
		return this;
	}

	public StatisticDeviceDTO page(Integer page) {
		if (page == null || page < 1 || page > 1000)
			page = 1;
		this.page = page;
		return this;
	}

}
